package com.faf.service.impl;

import java.sql.SQLException;

import com.faf.dao.StoreDao;
import com.faf.dao.impl.StoreDaoImpl;
import com.faf.dao.impl.UserDaoImpl;
import com.faf.service.StoreService;
import com.faf.tools.RSAUtils;

public class StoreServiceImpl implements StoreService{
	@Override
	public int CheckBusinessmanLogin(String storeNumber, String storePassword) throws SQLException {
		StoreDao sdi = new StoreDaoImpl();
		
		String sdi_UserPassword = sdi.getStoreByNumber(storeNumber).getStorePassword();
		sdi_UserPassword=RSAUtils.privateDecrypt(sdi_UserPassword);//数据库读取加密字串，进行解密
		
		System.out.println(sdi_UserPassword);
		if(sdi_UserPassword==null){
			System.out.println("用户不存在");
			return -1;
		}
		else if(storePassword.equals(sdi_UserPassword)){
			System.out.println("登陆成功");
			return 1;
		}
		else {
			System.out.println("密码不正确");
			return 0;
		}
		// TODO Auto-generated method stub
	}
}
